package com.eastfair.pay.chinaums.common.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class ParamUtil {


    public static String buildActiveBody(String merchantCode,String terminalCode){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        return JSONObject.toJSONString(map);
    }

    public static String buildPayBody(String merchantCode,String terminalCode,String transactionAmount,
                                      String transactionCurrencyCode,String merchantOrderId,
                                      String merchantRemark,String payMode,
                                      String payCode
                                      ){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        map.put("transactionAmount",transactionAmount);
        map.put("transactionCurrencyCode",transactionCurrencyCode);
        map.put("merchantOrderId",merchantOrderId);
        if ( merchantRemark!=null)map.put("merchantRemark",merchantRemark);
        map.put("payMode",payMode);
        map.put("payCode",payCode);
        return JSONObject.toJSONString(map);
    }

    public static String buildinvoiceBody(String invoiceMaterial,String invoiceType,String merchantId,
                                      String terminalId,String merOrderDate,
                                      String merOrderId,String amount
    ){
        Map map = new HashMap();
        map.put("invoiceMaterial",invoiceMaterial);
        map.put("invoiceType",invoiceType);
        map.put("merchantId",merchantId);
        map.put("terminalId",terminalId);
        map.put("merOrderDate",merOrderDate);
        //if ( merchantRemark!=null)map.put("merchantRemark",merchantRemark);
        map.put("merOrderId",merOrderId);
        map.put("amount",amount);
        return JSONObject.toJSONString(map);
    }

    public static String buildC2BBody(String requestTimestamp,String mid,String tid,String instMid,String totalAmount){
        Map map = new HashMap();
        map.put("requestTimestamp",requestTimestamp);
        map.put("mid",mid);
        map.put("tid",tid);
        map.put("instMid",instMid);
        map.put("totalAmount",totalAmount);
        return JSONObject.toJSONString(map);
    }

    public static String buildh5inquiryBody(String requestTimestamp,String mid,String tid,String instMid,String merOrderId){
        Map map = new HashMap();
        map.put("requestTimestamp",requestTimestamp);
        map.put("mid",mid);
        map.put("tid",tid);
        map.put("instMid",instMid);
        map.put("merOrderId",merOrderId);
        return JSONObject.toJSONString(map);
    }

    public static String buildofficialBody(String requestTimestamp,String mid,String tid,String instMid,String merOrderId,String tradeType,String userId,String totalAmount){
        Map map = new HashMap();
        map.put("requestTimestamp",requestTimestamp);
        map.put("mid",mid);
        map.put("tid",tid);
        map.put("instMid",instMid);
        map.put("merOrderId",merOrderId);
        map.put("tradeType",tradeType);
        map.put("userId",userId);
        map.put("totalAmount",totalAmount);
        return JSONObject.toJSONString(map);
    }

    public static String buildQueyBody(String merchantCode,String terminalCode,String merchantOrderId){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        map.put("merchantOrderId",merchantOrderId);
        return JSONObject.toJSONString(map);
    }
    public static String buildQueyBody2(String merchantCode,String terminalCode,String originalOrderId){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        map.put("originalOrderId",originalOrderId);
        return JSONObject.toJSONString(map);
    }

    public static String buildVoidpaymentBody(String merchantCode,String terminalCode,String originalOrderId){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        map.put("originalOrderId",originalOrderId);
        return JSONObject.toJSONString(map);
    }

    public static String buildRefundBody(String merchantCode,String terminalCode,String originalOrderId,String refundRequestId,String transactionAmount){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        map.put("originalOrderId",originalOrderId);
        map.put("refundRequestId",refundRequestId);
        map.put("transactionAmount",transactionAmount);
        return JSONObject.toJSONString(map);
    }
    public static String buildRefundBody2(String merchantCode,String terminalCode,String merchantOrderId,String refundRequestId,String transactionAmount){
        Map map = new HashMap();
        map.put("merchantCode",merchantCode);
        map.put("terminalCode",terminalCode);
        map.put("merchantOrderId",merchantOrderId);
        map.put("refundRequestId",refundRequestId);
        map.put("transactionAmount",transactionAmount);
        return JSONObject.toJSONString(map);
    }

    public static String buildTokenParam(String appId,String timestamp,String nonce,String signature){
        Map map = new HashMap();
        map.put("appId",appId);
        map.put("timestamp",timestamp);
        map.put("nonce",nonce);
        map.put("signature",signature);
        return JSONObject.toJSONString(map);
    }
}
